﻿/**
*公共函数，空值，网络连接等
*
*/
function NotifyEmptyResult() {
	alert("结果为空！");
}
function NotifyTryAgain() {
	//alert("网络出错，请稍后再试！");
}
function initData(){
	
}
/**
*公共请求函数
*/
function ajaxAbstract(method,remote_url,send_data,parser_callback,dom_callback){
	$.ajax({
		type: method,
		url: remote_url,
		dataType: 'json',
		data:send_data,
		success: function(result) {
			if (result == "" || result == null) {
				NotifyEmptyResult();
			} else {
				dom_callback(parser_callback(result));
			}
		},
		error: function(xhr, textStatus, errorThrown) {
			NotifyTryAgain();
		}
	});
}



	//会员登录
//function loginmodal(){
//	//var method="post";
//	//var URL="merchant_login.action";
	

//	////获取表单数据
//	//var formData="vipInfo.strName="+$("#memberLogName").val()
//    //            +"&vipInfo.strPasswd="+$("#memberLogKey").val();
//    //            alert(formData);
//	//ajaxAbstract(method,URL,formData,parseJson,DomInsert);
//    $.ajax({
//        url: "merchant_login", //对应action的路径
//        datatype: "json",
//        cache: false,
//        data: { name: $("#memberLogName").val(), passwd:$("#memberLogKey").val() },   //传给程英的商家id
//        type: "POST",
//        success: function (data) {
//            var obj = JSON.parse(data);
//            if (obj < 0)
//                alert("登录失败");
//            else if (obj > 0)
//                location.href = "LoggedMember.html?id=" + obj;
//        }
//        });
//    location.href = "LoggedMember.html?id=zlz";

//}
//商家登陆
function loginmodal2(){
	var method="post";
	var URL="vIP_login.action";
	

	//获取表单数据
	var formData="merchant.strName="+$("#merchantLogName").val()
                +"&merchant.strPasswd="+$("#merchantLogKey").val();
                alert(formData);
	ajaxAbstract(method,URL,formData,parseJson,DomInsert);


}
//dom插入
function DomInsert(str)
{
	var $boxes = $(str);
	//var $newInsert = $('#sample').html( $boxes );
	showDlg(infoDlgId,infoTextId,str);
}
//格式化数据
function parseJson(data)
{
	//var html="";
	//$.each(data.res,function(i,item){
	//	html=html+"<tr><td>"+item.name+"</td><td>"+item.percetage+"</td></tr>"
	//});
	return data.state;
}

//添加button绑定事件
$(document).ready(function() {
	////person_apply();
	//$('#memberLog').click(function(){loginmodal();});
	//$('#merchantLog').click(function(){loginmodal2();});
});
